<template>
	<view class="container">
		<u-top-tips ref="uTips"></u-top-tips>
		<u-form :model="addMerForm" :rules="merFormRules" ref="merFormRef" label-width="5rem">
			<!-- 			<u-form-item label="商户号" prop="merchant">
				<u-input v-model="addMerForm.merchant" />
			</u-form-item> -->
			<u-form-item label-position="left" label="商户类型">
				<text v-if="addMerForm.merchant_type==1">企业商户</text>
				<text v-else-if="addMerForm.merchant_type==2">事业单位商户</text>
				<text v-else-if="addMerForm.merchant_type==3">个体工商户</text>
				<text v-else-if="addMerForm.merchant_type==4">个人商户</text>
				<text v-else-if="addMerForm.merchant_type==5">自然人</text>
				<text v-else>其他组织</text>
			</u-form-item>
			<u-form-item label-position="left" label="营业执照" prop="business_license" label-width="150" v-if="addMerForm.merchant_type==1||addMerForm.merchant_type==2||addMerForm.merchant_type==3||addMerForm.merchant_type==6">
				<u-upload :show-progress="false" :file-list="sanheyiList" action="http://openpay.duolaibei.com/admin/upload/businessLicense"
				 name="image" max-count="1" width="160" height="160" @on-choose-complete="upLoadBefore" @on-success="sanheyiUpSuccess"
				 @on-error="upLoadImgError"></u-upload>
			</u-form-item>
			<u-form-item label="商户名称" prop="user_name">
				<u-input v-model="addMerForm.user_name" />
			</u-form-item>
			<u-form-item label="商户简称" prop="nick_name">
				<u-input v-model="addMerForm.nick_name" />
			</u-form-item>
			<u-form-item label="组织机构代码" prop="org_num" v-if="addMerForm.merchant_type==1||addMerForm.merchant_type==2||addMerForm.merchant_type==3||addMerForm.merchant_type==6">
				<u-input v-model="addMerForm.org_num" />
			</u-form-item>
			<u-form-item label="联系地址" prop="address">
				<u-input v-model="addMerForm.address" />
			</u-form-item>
			<u-form-item label-position="left" label="开户许可证" prop="opening_account" label-width="150" v-if="addMerForm.merchant_type==1||addMerForm.merchant_type==2||addMerForm.merchant_type==6">
				<u-upload :show-progress="false" :file-list="kaihuxukeList" action="http://openpay.duolaibei.com/admin/upload/upload"
				 name="image" max-count="1" width="160" height="160" @on-choose-complete="upLoadBefore" @on-success="kaihuxukeUpSuccess"
				 @on-error="upLoadImgError"></u-upload>
			</u-form-item>
			<u-form-item label="开户银行" prop="bank_name">
				<u-input v-model="addMerForm.bank_name" />
			</u-form-item>
			<u-form-item label="开户名" prop="account_name">
				<u-input v-model="addMerForm.account_name" />
			</u-form-item>
			<u-form-item label="开户账号" prop="account_no">
				<u-input v-model="addMerForm.account_no" />
			</u-form-item>
			<u-form-item label-position="left" label="结算卡 " label-width="150" v-if="addMerForm.merchant_type==3">
				<u-upload :show-progress="false" :file-list="jiesuankaList" action="http://openpay.duolaibei.com/admin/upload/upload"
				 name="image" max-count="1" width="160" height="160" @on-choose-complete="upLoadBefore" @on-success="jiesuankaUpSuccess"
				 @on-error="upLoadImgError"></u-upload>
			</u-form-item>
			<u-form-item label="邮箱" prop="email">
				<u-input v-model="addMerForm.email" />
			</u-form-item>
			<u-form-item label="移动电话">
				<u-input v-model="addMerForm.mobile" />
			</u-form-item>
			<u-form-item label="固定电话">
				<u-input v-model="addMerForm.tel" />
			</u-form-item>
			<u-form-item label-position="left" label="证件类型" prop="cert_type">
				<u-radio-group v-model="addMerForm.cert_type" @change="radioGroupChange" width="auto" :wrap="false">
					<u-radio shape="circle" v-for="(item, index) in certTypeList" :key="index" :name="item.label">{{ item.label }}</u-radio>
				</u-radio-group>
			</u-form-item>
			<u-form-item label-position="left" label="身份证正面" prop="front_card" label-width="150">
				<u-upload :show-progress="false" :file-list="cardfortList" action="http://openpay.duolaibei.com/admin/upload/idcardFront"
				 name="image" max-count="1" width="160" height="160" @on-choose-complete="upLoadBefore" @on-success="cardFrontUpSuccess"
				 @on-error="upLoadImgError"></u-upload>
			</u-form-item>
			<u-form-item label-position="left" label="身份证反面" prop="back_card" label-width="150">
				<u-upload :show-progress="false" :file-list="cardbackList" action="http://openpay.duolaibei.com/admin/upload/idcardBack"
				 name="image" max-count="1" width="160" height="160" @on-choose-complete="upLoadBefore" @on-success="cardBackUpSuccess"
				 @on-error="upLoadImgError"></u-upload>
			</u-form-item>
			<u-form-item label="法人名字" prop="legal_person">
				<u-input v-model="addMerForm.legal_person" />
			</u-form-item>
			<u-form-item label="法人身份证号" prop="legal_person_id">
				<u-input v-model="addMerForm.legal_person_id" />
			</u-form-item>
			<u-form-item label="身份证起日期" prop="id_card_start_date">
				<u-input v-model="addMerForm.id_card_start_date" />
			</u-form-item>
			<u-form-item label="身份证始日期" prop="id_card_end_date">
				<u-input v-model="addMerForm.id_card_end_date" />
			</u-form-item>
			<u-form-item label="联系人姓名" prop="linkman">
				<u-input v-model="addMerForm.linkman" />
			</u-form-item>
			<u-form-item label="联系人电话" prop="link_phone">
				<u-input v-model="addMerForm.link_phone" />
			</u-form-item>
			<u-form-item label="结算卡联行号" prop="bank_code">
				<u-input v-model="addMerForm.bank_code" />
			</u-form-item>
			<u-form-item label-position="left" label="结算卡类型" prop="settle_bank_type">
				<u-radio-group v-model="addMerForm.settle_bank_type" @change="radioGroupChange" width="auto" :wrap="false">
					<u-radio shape="circle" v-for="(item, index) in sltBankTypeList" :key="index" :name="item.label">{{ item.label }}</u-radio>
				</u-radio-group>
			</u-form-item>
			<u-form-item label-position="left" label="入账标识" prop="settle_type">
				<u-radio-group v-model="addMerForm.settle_type" @change="radioGroupChange" width="auto" :wrap="false">
					<u-radio shape="circle" v-for="(item, index) in bookedTypeList" :key="index" :name="item.name">{{ item.name }}</u-radio>
				</u-radio-group>
			</u-form-item>
			<u-form-item label-position="left" label="经营类别" prop="merchant_category">
				<u-input :border="false" type="select" :select-open="busTypeShow" v-model="addMerForm.merchant_category"
				 placeholder="请选择经营类别" @click="busTypeShow = true"></u-input>
			</u-form-item>
			<u-form-item label-position="left" label="行业类型编码" prop="industry_type_code">
				<u-input :border="false" type="select" :select-open="indTypeShow" v-model="addMerForm.industry_type_code"
				 placeholder="请选择经营类别" @click="indTypeShow = true"></u-input>
			</u-form-item>
			<u-form-item label="商户费率" prop="service_rate">
				<u-input v-model="addMerForm.service_rate" />
			</u-form-item>
			<u-form-item label-position="left" label="结算类型" prop="settlementPeriod">
				<u-radio-group v-model="addMerForm.settlementPeriod" @change="radioGroupChange" width="auto" :wrap="false">
					<u-radio shape="circle" v-for="(item, index) in sltTypeList" :key="index" :name="item.name">{{ item.name }}</u-radio>
				</u-radio-group>
			</u-form-item>
			<u-form-item label-position="left" label="手持身份证照" prop="handheld_card" label-width="150" v-if="addMerForm.merchant_type==4||addMerForm.merchant_type==5||addMerForm.settle_type=='非法人入账'">
				<u-upload :show-progress="false" :file-list="shouchiCardList" action="http://openpay.duolaibei.com/admin/upload/upload"
				 name="image" max-count="1" width="160" height="160" @on-choose-complete="upLoadBefore" @on-success="shouchiCardUpSuccess"
				 @on-error="upLoadImgError"></u-upload>
			</u-form-item>
			<u-form-item label-position="left" label="手持银行卡照" prop="handheld_bank" label-width="150" v-if="addMerForm.merchant_type==4||addMerForm.merchant_type==5||addMerForm.settle_type=='非法人入账'">
				<u-upload :show-progress="false" :file-list="shouchiBankList" action="http://openpay.duolaibei.com/admin/upload/upload"
				 name="image" max-count="1" width="160" height="160" @on-success="shouchiBankUpSuccess" @on-error="upLoadImgError"></u-upload>
			</u-form-item>
			<u-form-item label-position="left" label="结算人身份证正面" prop="front_settlement_card" label-width="150" v-if="addMerForm.merchant_type==3||addMerForm.merchant_type==4||addMerForm.merchant_type==5||addMerForm.settle_type=='非法人入账'">
				<u-upload :show-progress="false" :file-list="jiesuanrenTop" action="http://openpay.duolaibei.com/admin/upload/upload"
				 name="image" max-count="1" width="160" height="160" @on-choose-complete="upLoadBefore" @on-success="jiesuanrenTopUpSuccess"
				 @on-error="upLoadImgError"></u-upload>
			</u-form-item>
			<u-form-item label-position="left" label="结算人身份证反面" prop="back_settlement_card" label-width="150" v-if="addMerForm.merchant_type==3||addMerForm.merchant_type==4||addMerForm.merchant_type==5||addMerForm.settle_type=='非法人入账'">
				<u-upload :show-progress="false" :file-list="jiesuanrenDown" action="http://openpay.duolaibei.com/admin/upload/upload"
				 name="image" max-count="1" width="160" height="160" @on-choose-complete="upLoadBefore" @on-success="jiesuanrenDownUpSuccess"
				 @on-error="upLoadImgError"></u-upload>
			</u-form-item>
			<u-form-item label-position="left" label="室内照" prop="interior_photo" label-width="150">
				<u-upload :show-progress="false" :file-list="shineiList" action="http://openpay.duolaibei.com/admin/upload/upload"
				 name="image" max-count="1" width="160" height="160" @on-choose-complete="upLoadBefore" @on-success="shineiUpSuccess"
				 @on-error="upLoadImgError"></u-upload>
			</u-form-item>
			<u-form-item label-position="left" label="门头照" prop="sign_doard" label-width="150">
				<u-upload :show-progress="false" :file-list="mentouList" action="http://openpay.duolaibei.com/admin/upload/upload"
				 name="image" max-count="1" width="160" height="160" @on-choose-complete="upLoadBefore" @on-success="mentouUpSuccess"
				 @on-error="upLoadImgError"></u-upload>
			</u-form-item>
			<!-- 			<u-form-item label-position="left" label="商户状态" prop="status">
				<u-switch v-model="addMerForm.status" slot="right"></u-switch>
			</u-form-item> -->
			<u-form-item label-position="left" label="特殊资质(可选)" label-width="150">
				<u-upload :show-progress="false" action="http://openpay.duolaibei.com/admin/upload/upload" name="image" max-count="1"
				 width="160" height="160" @on-choose-complete="upLoadBefore" @on-success="teshuzizhiUpSuccess" @on-error="upLoadImgError"></u-upload>
			</u-form-item>
			<u-form-item label-position="left" label="补充图片(可选)" label-width="150">
				<u-upload :show-progress="false" action="http://openpay.duolaibei.com/admin/upload/upload" name="image" max-count="1"
				 width="160" height="160" @on-choose-complete="upLoadBefore" @on-success="buchongUpSuccess" @on-error="upLoadImgError"></u-upload>
			</u-form-item>
		</u-form>
		<view class="btns-area">
			<u-button @click="addMer" type="warning" :plain="true">提交</u-button>
		</view>
		<u-select mode="single-column" :list="merTypeList" v-model="selectMerType" @confirm="selectMerTypeConfirm"></u-select>
		<u-select mode="single-column" :list="busTypeList" v-model="busTypeShow" @confirm="selectBusTypeConfirm"></u-select>
		<u-select mode="single-column" :list="indTypeList" v-model="indTypeShow" @confirm="selectIndTypeConfirm"></u-select>
		<u-picker mode="time" v-model="timePickerShow" @confirm="regionConfirm"></u-picker>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				fileList: [],
				merType: 0,
				addMerForm: {
					// 需要上传回显的数据要提前写好
					account_name: '',
					account_no: '',
					bankName: '',
					address: '',
					org_num: '',
					legal_person: '',
					legal_person_id: '',
					id_card_start_date: '',
					id_card_end_date: '',
				},

				// 商户类型选框显隐
				selectMerType: false,
				// 商户类型选择
				merTypeList: [{
						value: 1,
						label: '企业商户'
					},
					{
						value: 2,
						label: '事业单位商户'
					},
					{
						value: 3,
						label: '个体工商户'
					},
					{
						value: 4,
						label: '个人商户'
					},
					{
						value: 5,
						label: '自然人'
					},
					{
						value: 6,
						label: '其他组织'
					}
				],
				// 经营类型选框显隐
				busTypeShow: false,
				// 经营类型选择
				busTypeList: [],
				// 行业类型选框显隐
				indTypeShow: false,
				// 行业类型选择
				indTypeList: [],
				// 证件类型选择
				certTypeList: [{
					label: '身份证',
					checked: true,
					disabled: false,
					value: 1
				}, ],
				// 结算类型选择
				sltTypeList: [{
						name: 'T1',
						disabled: false,
						value: 'T1'
					},
					{
						name: 'D1',
						disabled: false,
						value: 'D1'
					},
					{
						name: 'D0',
						disabled: false,
						value: 'D0'
					},
				],
				// 结算卡类型选择
				sltBankTypeList: [{
						label: '对公',
						value: 1
					},
					{
						label: '对私',
						value: 2
					},

				],
				statusList: [{
						name: '启用',
						value: 1
					},
					{
						name: '禁用',
						value: 2
					},
				],
				// 入账标识
				bookedTypeList: [{
						name: '法人入账',
						value: 1
					},
					{
						name: '非法人入账',
						value: 2
					},
				],
				// 图片回显
				sanheyiList: [],
				kaihuxukeList: [],
				jiesuankaList: [],
				cardfortList: [],
				cardbackList: [],
				shouchiCardList: [],
				shouchiBankList: [],
				jiesuanrenTop: [],
				jiesuanrenDown: [],
				shineiList: [],
				mentouList: [],
				// 时间picker选择器
				timePickerShow: false,
				// 时间选择器的类型
				timePickerType: '',
				// 语法校验
				merFormRules: {
					front_card: [{
						required: true,
						message: '请上传身份证正面',
						trigger: ['change', 'blur'],
						validator: (rule, value, callback) => {
							if (this.addMerForm.user_file.front_card == undefined) {
								return false
							}
							return true
						}
					}, ],
					back_card: [{
						required: true,
						message: '请上传身份证反面',
						trigger: ['change', 'blur'],
						validator: (rule, value, callback) => {
							if (this.addMerForm.user_file.back_card == undefined) {
								return false
							}
							return true
						}
					}, ],
					business_license: [{
						required: true,
						message: '请上传营业执照',
						validator: (rule, value, callback) => {
							if (this.addMerForm.user_file.business_license == undefined) {
								return false
							}
							return true
						}
					}, ],
					user_name: [{
						required: true,
						message: '请输入商户名称',
						trigger: 'blur',
					}, ],
					nick_name: [{
						required: true,
						message: '请输入商户简称',
						trigger: 'blur',
					}, ],
					email: [{
						required: true,
						message: '请输入商户邮箱',
						trigger: 'blur',
					}, ],
					cert_type: [{
						required: true,
						message: '请选择证件类型',
						trigger: 'change',
					}, ],
					legal_person: [{
						required: true,
						message: '请输入法人名字',
						trigger: 'blur',
					}, ],
					legal_person_id: [{
						required: true,
						message: '请输入法人身份证号',
						trigger: 'blur',
					}, ],
					org_num: [{
						required: true,
						message: '请输入组织机构代码证',
						trigger: 'blur',
					}, ],
					address: [{
						required: true,
						message: '请输入联系地址',
						trigger: 'blur',
					}, ],
					linkman: [{
						required: true,
						message: '请输入联系人姓名',
						trigger: 'blur',
					}, ],
					link_phone: [{
						required: true,
						message: '请输入联系人电话',
						trigger: 'blur',
					}, ],
					merchant_category: [{
						required: true,
						message: '请选择经营类别',
						trigger: 'blur',
					}, ],
					industry_type_code: [{
						required: true,
						message: '请选择行业类型编码',
						trigger: 'blur',
					}, ],
					id_card_start_date: [{
						required: true,
						message: '请选择身份证开始日期',
						trigger: 'blur',
					}, ],
					id_card_end_date: [{
						required: true,
						message: '请选择身份结束日期',
						trigger: 'blur',
					}, ],
					handheld_card: [{
						required: true,
						message: '请上传手持身份证照',
						validator: (rule, value, callback) => {
							if (this.addMerForm.user_file.handheld_card == undefined) {
								return false
							}
							return true
						}
					}, ],
					handheld_bank: [{
						required: true,
						message: '请上传手持银行卡照',
						validator: (rule, value, callback) => {
							if (this.addMerForm.user_file.handheld_bank == undefined) {
								return false
							}
							return true
						}
					}, ],
					opening_account: [{
						required: true,
						message: '请上传开户许可证',
						validator: (rule, value, callback) => {
							if (this.addMerForm.user_file.opening_account == undefined) {
								return false
							}
							return true
						}
					}, ],
					front_settlement_card: [{
						required: true,
						message: '请上传结算人身份证正面',
						validator: (rule, value, callback) => {
							if (this.addMerForm.user_file.front_settlement_card == undefined) {
								return false
							}
							return true
						}
					}, ],
					back_settlement_card: [{
						required: true,
						message: '请上传结算人身份证反面',
						validator: (rule, value, callback) => {
							if (this.addMerForm.user_file.back_settlement_card == undefined) {
								return false
							}
							return true
						}
					}, ],
					bank_code: [{
						required: true,
						message: '请输入结算卡联行号',
						trigger: 'blur',
					}, ],
					bank_name: [{
						required: true,
						message: '请输入开户银行',
						trigger: 'blur',
					}, ],
					account_name: [{
						required: true,
						message: '请输入开户名',
						trigger: 'blur',
					}, ],
					account_no: [{
						required: true,
						message: '请输入开户账号',
						trigger: 'blur',
					}, ],
					settle_type: [{
						required: true,
						message: '请选择入账标识',
						trigger: 'change',
					}],
					settle_bank_type: [{
						required: true,
						message: '请选择结算卡类型',
						trigger: 'change',
					}, ],
					service_rate: [{
						required: true,
						message: '请输入商户费率',
						trigger: 'blur',
					}, ],
					settlementPeriod: [{
						required: true,
						message: '请选择结算类型',
						trigger: 'change',
					}, ],
					interior_photo: [{
						required: true,
						message: '请上传室内照',
						validator: (rule, value, callback) => {
							if (this.addMerForm.user_file.interior_photo == undefined) {
								return false
							}
							return true
						}
					}, ],
					sign_doard: [{
						required: true,
						message: '请上传门头照',
						validator: (rule, value, callback) => {
							if (this.addMerForm.user_file.sign_doard == undefined) {
								return false
							}
							return true
						}
					}, ],
				}
			}
		},
		onLoad(options) {
			uni.showLoading({
				title: '努力加载中'
			});
			this.addMerForm = JSON.parse(options.info);
			this.getBusTypeList();
			this.getIndTypeList();
			this.setAddForm();
		},
		onReady() {
			this.$refs.merFormRef.setRules(this.merFormRules);
		},
		methods: {
			upLoadBefore() {
				uni.showLoading({
					title: '努力上传中',
					mask: true
				});
			},
			setAddForm() {
				let that = this,
					form = this.addMerForm,
					imgObj = {
						url: '',
					};
					
				form.cert_type = that.$myApi.valFindLabel(that.certTypeList, form.cert_type);
				form.settle_bank_type = that.$myApi.valFindLabel(that.sltBankTypeList, form.settle_bank_type);
				form.settle_type = that.$myApi.valFindLabel(that.bookedTypeList, form.settle_type);
				imgObj.url = form.user_file.business_license;
				that.sanheyiList.push(imgObj);
				imgObj = {
					url: ''
				};
				imgObj.url = form.user_file.opening_account;
				that.kaihuxukeList.push(imgObj);
				imgObj = {
					url: ''
				};
				imgObj.url = form.user_file.bank_card;
				that.jiesuankaList.push(imgObj);
				imgObj = {
					url: ''
				};
				imgObj.url = form.user_file.front_card;
				that.cardfortList.push(imgObj);
				imgObj = {
					url: ''
				};
				imgObj.url = form.user_file.back_card;
				that.cardbackList.push(imgObj);
				imgObj = {
					url: ''
				};
				imgObj.url = form.user_file.handheld_card;
				that.shouchiCardList.push(imgObj);
				imgObj = {
					url: ''
				};
				imgObj.url = form.user_file.handheld_bank;
				that.shouchiBankList.push(imgObj);
				imgObj = {
					url: ''
				};
				imgObj.url = form.user_file.front_settlement_card;
				that.jiesuanrenTop.push(imgObj);
				imgObj = {
					url: ''
				};
				imgObj.url = form.user_file.back_settlement_card;
				that.jiesuanrenDown.push(imgObj);
				imgObj = {
					url: ''
				};
				imgObj.url = form.user_file.interior_photo;
				that.shineiList.push(imgObj);
				imgObj = {
					url: ''
				};
				imgObj.url = form.user_file.sign_doard;
				that.mentouList.push(imgObj);
				imgObj = {
					url: ''
				};
				if (form.user_file.special_card) {
					imgObj.url = form.user_file.special_card;
					that.special_card.push(imgObj);
					imgObj = {
						url: ''
					};
				}
				if (form.user_file.supplement_photo) {
					imgObj.url = form.user_file.supplement_photo;
					that.supplement_photo.push(imgObj);
					imgObj = {
						url: ''
					};
				}
				that.addMerForm = form;
				uni.hideLoading();
			},
			cardFrontUpSuccess(data, index, lists, name) {
				let con=data.content;
				this.addMerForm.legal_person_id=con.idNumb;
				this.addMerForm.legal_person=con.name;
				this.addMerForm.user_file.front_card=con.path;
				uni.hideLoading();
			},
			cardBackUpSuccess(data, index, lists, name) {
				let con=data.content;
				this.addMerForm.id_card_start_date=con.starttime;
				this.addMerForm.id_card_end_date=con.overtime;
				this.addMerForm.user_file.back_card=con.path;
				uni.hideLoading();
			},
			sanheyiUpSuccess(data, index, lists, name) {
				let con=data.content;
				this.addMerForm.address=con.address;
				this.addMerForm.user_name=con.companyName;
				this.addMerForm.org_num=con.licenseNo
				this.addMerForm.user_file.business_license=con.path;
				uni.hideLoading();
			},
			kaihuxukeUpSuccess(data, index, lists, name) {
				let con = data.content;
				this.addMerForm.user_file.opening_account = con.path;
				uni.hideLoading();
			},
			shouchiCardUpSuccess(data, index, lists, name) {
				let con=data.content;
				this.addMerForm.user_file.handheld_card=con.path;
				uni.hideLoading();
			},

			shineiUpSuccess(data, index, lists, name) {
				let con = data.content;
				this.addMerForm.user_file.interior_photo = con.path;
				uni.hideLoading();
			},
			mentouUpSuccess(data, index, lists, name) {
				let con = data.content;
				this.addMerForm.user_file.sign_doard = con.path;
				uni.hideLoading();
			},
			shouchiBankUpSuccess(data, index, lists, name) {
				let con=data.content;
				this.addMerForm.user_file.handheld_bank=con.path;
				uni.hideLoading();
			},
			jiesuankaUpSuccess(data, index, lists, name) {
				let con = data.content;
				this.addMerForm.user_file.bank_card = con.path;
				uni.hideLoading();
			},
			jiesuanrenTopUpSuccess(data, index, lists, name) {
				let con = data.content;
				this.addMerForm.user_file.front_settlement_card = con.path;
				uni.hideLoading();
			},
			jiesuanrenDownUpSuccess(data, index, lists, name) {
				let con = data.content;
				this.addMerForm.user_file.back_settlement_card = con.path;
				uni.hideLoading();
			},
			teshuzizhiUpSuccess(data, index, lists, name) {
				let con = data.content;
				this.addMerForm.user_file.special_card = con.path;
				uni.hideLoading();
			},
			buchongUpSuccess(data, index, lists, name) {
				let con = data.content;
				this.addMerForm.user_file.supplement_photo = con.path;
				uni.hideLoading();
			},
			// 图片上传失败
			upLoadImgError() {
				// this.$refs.uTips.show({
				// 	title: '上传失败',
				// 	type: 'error',
				// 	duration: '2000'
				// })
			},
			// 点击actionSheet回调
			actionSheetCallback(index) {
				uni.hideKeyboard();
				this.addMerForm.gender = this.actionSheetList[index].text;
			},
			// 选择商品类型回调
			selectMerTypeConfirm(e) {
				let that = this;
				this.addMerForm.merchant_type = '';
				e.map((val, index) => {
					that.addMerForm.merchant_type += that.addMerForm.merchant_type == '' ? val.label : '-' + val.label;
					that.merType = val.value;
				});
			},
			// 身份类型选择发生变化
			radioGroupChange(e) {

			},
			openTimePicker(e) {
				this.timePickerShow = true;
				this.timePickerType = e;
			},
			// 选择日期回调
			regionConfirm(e) {
				switch (this.timePickerType) {
					case "start":
						this.addMerForm.id_card_start_date = e.year + '-' + e.month + '-' + e.day;
						break;
					case "end":
						this.addMerForm.id_card_end_date = e.year + '-' + e.month + '-' + e.day;
						break;
					default:
				}
			},
			selectBusTypeConfirm(e) {
				let that = this;
				this.addMerForm.merchant_category = '';
				e.map((val, index) => {
					that.addMerForm.merchant_category = val.label;
				});
			},
			selectIndTypeConfirm(e) {
				let that = this;
				this.addMerForm.industry_type_code = '';
				e.map((val, index) => {
					that.addMerForm.industry_type_code = val.label;
				});
			},
			// 添加商户
			addMer() {
				let that = this,
					form = this.addMerForm;
				this.$refs.merFormRef.validate(valid => {
					if (valid) {
						uni.showModal({
							title: '提示',
							content: '是否确认编辑商户',
							success: function(res) {
								if (res.confirm) {
									that.$request.httpTokenRequest({
										url: '/admin/general/setUser',
										method: 'POST',
										data: {
											userID: form.id,
											agent_id: form.agent_id,
											user_name: form.user_name,
											nick_name: form.nick_name,
											email: form.email,
											mobile: form.mobile,
											tel: form.tel,
											merchant_type:form.merchant_type,
											cert_type: that.$myApi.labelFindVal(that.certTypeList, form.cert_type),
											legal_person: form.legal_person,
											legal_person_id: form.legal_person_id,
											id_card_start_date: form.id_card_start_date,
											id_card_end_date: form.id_card_end_date,
											org_num: form.org_num,
											address: form.address,
											linkman: form.linkman,
											link_phone: form.link_phone,
											bank_code: form.bank_code,
											account_name: form.account_name,
											account_no: form.account_no,
											bank_name: form.bank_name,
											settle_bank_type: that.$myApi.labelFindVal(that.sltBankTypeList, form.settle_bank_type),
											settle_type: that.$myApi.labelFindVal(that.bookedTypeList, form.settle_type),
											merchant_category: form.merchant_category,
											industry_type_code: form.industry_type_code,
											service_rate: form.service_rate,
											settlementPeriod: that.$myApi.labelFindVal(that.sltTypeList, form.settlementPeriod),
											status: 0,
											userFile: JSON.stringify(form.user_file)
										},
										needToken: false,
									}).then(res => {
										if (res.data.code === 200) {
											uni.showToast({
												title:"更新成功",
												icon:'none',
												duration:2000
											});
											uni.navigateBack();
										}else{
											uni.showToast({
												title:res.data.msg,
												icon:'none',
												duration:2000
											});
										}
									}, error => {
									});
								}
							},
						})

					} else {
					}
				});
			},
			getBusTypeList() {
				let that = this;
				this.$request.httpTokenRequest({
					url: '/admin/conf/getCategory',
					method: 'POST',
					data: {
						type: 0
					},
					needToken: false,
				}).then(res => {
					if (res.data.code == 200) {
						that.busTypeList = res.data.content;
					}
				}, error => {
				});
			},
			getIndTypeList() {
				let that = this;
				this.$request.httpTokenRequest({
					url: '/admin/conf/getIndustry',
					method: 'POST',
					data: {
						type: 0
					},
					needToken: false,
				}).then(res => {
					if (res.data.code == 200) {
						that.indTypeList = res.data.content;
					}
				}, error => {
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		width: 96%;
		margin: 0 auto;
		padding-bottom: 2rem;

		.btns-area {
			margin-top: 2rem;
		}
	}
</style>
